home *** CD-ROM | disk | FTP | other *** search
- public class StringUtil {
- public static String[] sortString(String[] items) {
- for(int c = 0; c < items.length; ++c) {
- for(int i = 0; i < items.length - 1; ++i) {
- if (items[i].compareTo(items[i + 1]) > 0) {
- String temp = items[i];
- items[i] = items[i + 1];
- items[i + 1] = temp;
- }
- }
- }
-
- return items;
- }
-
- public static boolean contains(String source, String match) throws Exception {
- if (source.length() < match.length()) {
- throw new Exception("String to match is longer than source! (" + source + " < " + match + ")");
- } else {
- try {
- for(int i = 0; i < source.length() - match.length() + 1; ++i) {
- if (source.substring(i, i + match.length()).equalsIgnoreCase(match)) {
- return true;
- }
- }
-
- return false;
- } catch (Exception var3) {
- throw new Exception("Error searching for " + match + " in " + source + "\n" + var3);
- }
- }
- }
-
- public static int positionOf(String source, String subString) throws Exception {
- if (source.length() < subString.length()) {
- throw new Exception("Sub string is longer than source! (" + source + " < " + subString + ")");
- } else {
- try {
- for(int i = 0; i < source.length() - subString.length() + 1; ++i) {
- if (source.substring(i, i + subString.length()).equals(subString)) {
- return i;
- }
- }
-
- return -1;
- } catch (Exception var3) {
- throw new Exception("Error searching for " + subString + " in " + source + "\n" + var3);
- }
- }
- }
-
- public static String getFileName(String filePath) throws Exception {
- try {
- for(int i = filePath.length() - 1; i > 0; --i) {
- if (filePath.charAt(i) == '/') {
- return filePath.substring(i + 1, filePath.length());
- }
- }
-
- return null;
- } catch (Exception var2) {
- throw new Exception("Error getting path from " + filePath + "\n" + var2);
- }
- }
-
- public static String getPath(String filePath) throws Exception {
- try {
- for(int i = filePath.length() - 1; i > 0; --i) {
- if (filePath.charAt(i) == '/') {
- return filePath.substring(0, i);
- }
- }
-
- return null;
- } catch (Exception var2) {
- throw new Exception("Error getting path from " + filePath + "\n" + var2);
- }
- }
-
- public static String getExtension(String filePath) throws Exception {
- try {
- for(int i = filePath.length() - 1; i > 0; --i) {
- if (filePath.charAt(i) == '.') {
- return filePath.substring(i, filePath.length());
- }
- }
-
- return null;
- } catch (Exception var2) {
- throw new Exception("Error getting path from " + filePath + "\n" + var2);
- }
- }
-
- public static String toLowerCase(String theString) {
- String temp = "";
- temp = theString.toLowerCase();
- return temp;
- }
- }
-